<?php
/**
 * 熵巡 - 企业级氚云OpenAPI数据管理平台
 * 开发归属 Alyr.net
 * 获取数据库状态接口 - 读取所有数据库启用状态
 * 尊重劳动成果是一种美德
 */

header('Content-Type: application/json');

try {
    $configFile = __DIR__ . '/../config.php';
    
    if (!file_exists($configFile)) {
        echo json_encode(['success' => false, 'message' => '配置文件不存在']);
        exit;
    }
    
    $config = include $configFile;
    
    if (!isset($config['databases'])) {
        echo json_encode(['success' => false, 'message' => '数据库配置不存在']);
        exit;
    }
    
    $databaseStates = [];
    $supportedTypes = ['mysql', 'tdsql_c', 'sql_server', 'postgresql'];
    
    foreach ($supportedTypes as $type) {
        $databaseStates[$type] = $config['databases'][$type]['enabled'] ?? false;
    }
    
    echo json_encode([
        'success' => true,
        'database_states' => $databaseStates
    ]);
    
} catch (Exception $e) {
    echo json_encode(['success' => false, 'message' => '获取状态失败: ' . $e->getMessage()]);
}
exit;